﻿<phone:PhoneApplicationPage
    x:Class="GoStats.Views.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
	xmlns:vmi="clr-namespace:GoStats.ViewModels"
    d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <vmi:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <vmi:BooleanToVisibilityInversed x:Key="BooleanToVisibilityInversed"/>
    </phone:PhoneApplicationPage.Resources>

    <!--Data context is set to sample data above and LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- LOCALIZATION NOTE:
            To localize the displayed strings copy their values to appropriately named
            keys in the app's neutral language resource file (AppResources.resx) then
            replace the hard-coded text value between the attributes' quotation marks
            with the binding clause whose path points to that string name.

            For example:

                Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"

            This binding points to the template's string resource named "ApplicationTitle".

            Adding supported languages in the Project Properties tab will create a
            new resx file per language that can carry the translated values of your
            UI strings. The binding in these examples will cause the value of the
            attributes to be drawn from the .resx file that matches the
            CurrentUICulture of the app at run time.
         -->

        <!--TitlePanel contains the name of the application and page title-->
        <Grid>
            <Grid.Background>
                <ImageBrush Stretch="Fill" ImageSource="/GoStats;component/Assets/header_bg.jpg"/>
            </Grid.Background>
        </Grid>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,14">
            <TextBlock Text="GoStats Live" Style="{StaticResource PhoneTextNormalStyle}" Foreground="White" FontSize="22.667"/>
            <TextBlock Text="My Websites" Margin="9,10,0,0" Style="{StaticResource PhoneTextTitle1Style}" Foreground="White" FontSize="46.667"/>
        </StackPanel>

        <!--ContentPanel contains LongListSelector and LongListSelector ItemTemplate. Place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <phone:LongListSelector x:Name="MainLongListSelector" Margin="0,0,-12,0" ItemsSource="{Binding Items}" SelectionChanged="MainLongListSelector_SelectionChanged" Foreground="Black">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,0,0,2">
                            <Border BorderBrush="#FF91A889" BorderThickness="0,0,0,1">
                                <TextBlock Text="{Binding SiteDetails.Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Foreground="#FF318A17" Margin="12,20,10,10" FontSize="26.667"/>
                            </Border>
                        </StackPanel>
                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>
        </Grid>
        <Grid x:Name="progress" Grid.Row="1" Background="#FF759D16" Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}">
            <ProgressBar Height="10" VerticalAlignment="Center" Foreground="White" IsIndeterminate="True"/>
        </Grid>
        <Grid x:Name="error" Grid.Row="1" Background="#FF759D16" Visibility="{Binding IsFailed, Converter={StaticResource BooleanToVisibilityConverter}}">
            <TextBlock TextWrapping="Wrap" Text="Network error or outdated program." VerticalAlignment="Center" TextAlignment="Center"/>
        </Grid>
        <Grid x:Name="login" Grid.Row="1" Background="#FF759D16" Visibility="{Binding IsLoginPage, Converter={StaticResource BooleanToVisibilityConverter}}">
        	<Grid.RowDefinitions>
        		<RowDefinition/>
        		<RowDefinition Height="Auto"/>
        		<RowDefinition/>
        	</Grid.RowDefinitions>
        	<StackPanel VerticalAlignment="Top" Grid.Row="1">
        		<TextBlock TextWrapping="Wrap" Text="Username:" VerticalAlignment="Center" TextAlignment="Center" Margin="0" FontSize="26.667"/>
                <TextBox Height="72" TextWrapping="Wrap" Foreground="#FF16440C" Text="{Binding UsernameBox, Mode=TwoWay}" BorderThickness="3" MaxWidth="320" Padding="20,2,2,2"/>
        		<TextBlock TextWrapping="Wrap" Text="Password:" VerticalAlignment="Center" TextAlignment="Center" Margin="0" FontSize="26.667"/>
                <PasswordBox Height="72" Foreground="#FF16440C" Password="{Binding PasswordBox, Mode=TwoWay}" BorderThickness="3" MaxWidth="320" Padding="20,2,2,2"/>
        		<Button Content="Login" MaxWidth="200" Click="Button_Click"/>
        	</StackPanel>
            <TextBlock TextWrapping="Wrap" Text="Network error or wrong password" VerticalAlignment="Top" TextAlignment="Center" Margin="0,20,0,0" FontSize="21.333" Grid.Row="2" Visibility="{Binding IsFailed, Converter={StaticResource BooleanToVisibilityConverter}}"/>
            <ProgressBar Height="10" VerticalAlignment="Top" Grid.Row="2" Margin="0,30,0,0" IsIndeterminate="True" Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        </Grid>

        <!--Uncomment to see an alignment grid to help ensure your controls are
            aligned on common boundaries.  The image has a top margin of -32px to
            account for the System Tray. Set this to 0 (or remove the margin altogether)
            if the System Tray is hidden.

            Before shipping remove this XAML and the image itself.-->
        <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" BackgroundColor="White" ForegroundColor="#FF759D16">
            <shell:ApplicationBarIconButton Click="ApplicationBarIconButton_Refresh" IconUri="/Assets/Icons/sync.png" Text="Refresh" IsEnabled="True"/>
            <shell:ApplicationBarIconButton Click="ApplicationBarIconButton_Logout" IconUri="/Assets/Icons/cancel.png" Text="Logout" IsEnabled="True"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>